#!/bin/bash

# Runs any hooks in misc/git/hooks, and exits if any of them fail.
set -e

# This is necessary because the Emacs extensions don't set GIT_DIR.
if [ -z "$GIT_DIR" ]; then
  DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
  GIT_DIR="${DIR}/.."
fi

# This is necessary because the Atom packages don't set GOPATH
if [ -z "$GOPATH" ]; then
  GOPATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )/../../../../../.." && pwd )
  export GOPATH
fi

for hook in $GIT_DIR/../misc/git/hooks/*; do
  $hook
done
